from Linac import *
from globals import loadLinacInfo, meminfo
import time as t

fdir = '/home/ainswort/HOMDynamics/LatticeFiles/'

#####Build linac#####
Drifts = loadLinacInfo(fdir+'HS_2011_11_23_Plasma-Surface_To_Target.txt','DR_13','DR_493')[0] 

Spokes = CavitySection(file=fdir+'spokesnew.csv')
Spokes.loadField(fdir+'Ezvszspoke.dat',Spokes.beta_G,Spokes.V_rf)

#####Create Pulse#####
numBunches = 5e4
tb = 1/352.2e6
#tb = 2.84e-9
Ib = 400e-3
P1 = Pulse(numBunches,Cavities.cavNum, tb, Ib)
P1.Ibsig = 40e-3
P1.dq = dq


#####Create HOMs#####
homfreq = 2.2838e9
homQex = 1e8
homRoverQ = 100

H1 = HOM(Cavities.cavNum,homfreq,homQex,homRoverQ)
H1.fsig = 0.1e6
H1.freq = homfreqJT


#####Create Linac ready to track#####
Lin = Linac(Cavities,Drifts,P1, H1)
Lin.info()
t0 = t.time()
Lin.Track()
print 'Tracked', int(P1.numBunches), 'bunches in', t.time() - t0, 'secs'
meminfo()

